package com.hzhr.iot.user.service;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.CygService;
import com.hzhr.iot.core.constant.AccessModeEnum;
import com.hzhr.iot.core.constant.CommonOptions;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.login.sdk.model.token.TokenModel;
import com.hzhr.iot.login.sdk.service.Login_TokenService;
import com.hzhr.iot.user.Global;
import com.hzhr.iot.user.constant.UserOptions;
import com.hzhr.iot.user.constant.UserOptionsName;
import com.hzhr.iot.user.constant.UserOptionsTypeName;
import com.hzhr.iot.user.constant.User_ErrorsEnum;
import com.hzhr.iot.user.convertor.custom.UserCustomConvertor;
import com.hzhr.iot.user.dao.UserDao;
import com.hzhr.iot.user.dao.UserInRoleDao;
import com.hzhr.iot.user.dao.helper.UserInRoleDaoHelper;
import com.hzhr.iot.user.entity.UserEntity;
import com.hzhr.iot.user.entity.UserInRoleEntity;
import com.hzhr.iot.user.entity.ext.UserEntityExt;
import com.hzhr.iot.user.model.user_registInfo.User_RegistInfoGetModel;
import com.hzhr.iot.user.model.user_registInfo.User_RegistInfoModel;
import com.hzhr.iot.user.model.user_registInfo.User_RegistInfoPostModel;
import com.hzhr.iot.user.queryModel.custom.UserCustomQueryModel;
import com.hzhr.iot.user.service.base.BaseService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@CygService(entity = UserEntity.class, model = User_RegistInfoModel.class)
public class User_RegistInfoService extends BaseService {
    @Autowired
    UserDao userDao;
    @Autowired
    Login_TokenService login_tokenService;
    @Autowired
    UserService userService;
    @Autowired
    UserOptions userOptions;
    @Autowired
    UserCustomConvertor userCustomConvertor;
    @Autowired
    User_RegistInfoService user_registInfoService;
    @Autowired
    UserInRoleDaoHelper userInRoleDaoHelper;
    @Autowired
    UserInRoleDao userInRoleDao;

    @Autowired
    Global global;

    //region javadoc注释 : post
    /**
     * 新用户注册 <br/><br/>
     * 简介&nbsp;:&nbsp;创建用户；登录 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;验证用户名&nbsp;:&nbsp;(√) <br/>
     * &nbsp;查询“userName&nbsp;=&nbsp;body.phone的用户(USER)”是否存在，如果存在，抛出异常201；(√) <br/>
     * 2.&nbsp;创建用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据body创建用户user_1，同时设置以下属性： <br/>
     * &nbsp;(1)&nbsp;user_1.phone&nbsp;=&nbsp;body.phone； <br/>
     * &nbsp;(2)&nbsp;user_1.companyId&nbsp;=&nbsp;0； <br/>
     * &nbsp;(3)&nbsp;user_1.deptId&nbsp;=&nbsp;0； <br/>
     * &nbsp;(4)&nbsp;user_1.isNewUser&nbsp;=&nbsp;否； <br/>
     * &nbsp;(5)&nbsp;user_1.userCode&nbsp;=&nbsp;'0'； <br/>
     * &nbsp;(6)&nbsp;user_1.resourceCode&nbsp;=&nbsp;'0'； <br/>
     * 3.&nbsp;提交以上事务 <br/>
     * 4.&nbsp;登录&nbsp;:&nbsp;(√) <br/>
     * &nbsp;使用user_1.userName和user_1.password调用登录服务(login-service:&nbsp;/tokens&nbsp;GET)进行登录； <br/>
     * 5.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据条件参数查询更新结果，组装响应并返回； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/><br/>
     * @param body <br/><br/>
     * @throws ServiceException <br/>
     * USER_REGISTINFOSERVICE_POST_201 : <br/>&nbsp&nbsp&nbsp&nbsp异常类型 : 业务流程异常<br/>&nbsp&nbsp&nbsp&nbsp异常业务 : 判断手机号的唯一性<br/>&nbsp&nbsp&nbsp&nbsp异常描述 : 手机号已注册<br/>
     * @see User_RegistInfoPostModel body <br/>
     * @see User_RegistInfoGetModel result <br/>
     */ 
    //endregion
    //region 说明 : post
    //新用户注册
    //简介 : 创建用户；登录
    //步骤 :
    //1. 验证用户名 : (√)
    // 查询“userName = body.phone的用户(USER)”是否存在，如果存在，抛出异常201；(√)
    //2. 创建用户 : (√)
    // 根据body创建用户user_1，同时设置以下属性：
    // (1) user_1.phone = body.phone；
    // (2) user_1.companyId = 0；
    // (3) user_1.deptId = 0；
    // (4) user_1.isNewUser = 否；
    // (5) user_1.userCode = '0'；
    // (6) user_1.resourceCode = '0'；
    //3. 提交以上事务
    //4. 登录 : (√)
    // 使用user_1.userName和user_1.password调用登录服务(login-service: /tokens GET)进行登录；
    //5. 返回信息 : (√)
    // 根据条件参数查询更新结果，组装响应并返回；
    //endregion
    //region 参数 : post
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            
            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })

    //endregion
    //region 请求 : post
    @RequestMapping(value = "/users/regist-infos", method = RequestMethod.POST)
    //endregion
    public User_RegistInfoGetModel post(Map<String, String> header, Map<String, Object> query,
                                          User_RegistInfoPostModel body) throws ServiceException {
        /* 验证用户名 */
        long phone = body.getPhone();
        UserCustomQueryModel userCustomQueryModel = new UserCustomQueryModel();
        userCustomQueryModel.setEqual_userName(phone + "");
        userCustomQueryModel.setEqual_isValid(CommonOptions.YES_NO.YES);
        int existCount = userDao.selectCount(userCustomQueryModel);
        if (existCount > 0) {
            throw new ServiceException(User_ErrorsEnum.USER_REGISTINFOSERVICE_POST_201);
        }

        /* 创建用户 */
        UserEntity user_1 = new UserEntity();
        user_1.setUserName(phone + "");
        user_1.setPhone(phone);
        user_1.setPassword(body.getPassword());
        user_1.setCompanyId(0);
        user_1.setDeptId(0);
        user_1.setEmail(body.getEmail());
        user_1.setIsNewUser(CommonOptions.YES_NO.YES);
        user_1.setCreateTime(new Date());
        user_1.setCreateUserId(0);
        user_1.setUserCode("0");
        user_1.setResourceCode("0");
        user_1.setIsValid(CommonOptions.YES_NO.YES);
        user_1.setState("1");
        user_1.setType(userOptions.getCode(UserOptionsTypeName.USER_TYPE, UserOptionsName.USER_TYPE.FREE));
        int changeCount = userDao.insert(user_1);

        /* 提交以上事务 */

        /* 登陆 */
        Map<String, String> header1 = new HashMap<>();
        header1.put("user-name", user_1.getUserName());
        header1.put("password", user_1.getPassword());
        Map<String, Object> query1 = new HashMap<>();
        TokenModel tokenModel = login_tokenService.get(header1, query1);

        /* 返回信息 */
        query.put("_equal_id", user_1.getId());
        User_RegistInfoGetModel result = user_registInfoService.get(initHeader(header, AccessModeEnum.GLOBAL), query);
        result.setChangeCount(changeCount);
        return result;
    }

    //region javadoc注释 : post1
    /**
     * 新用户注册 <br/><br/>
     * 简介&nbsp;:&nbsp;创建用户；登录 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;验证用户名&nbsp;:&nbsp;(√) <br/>
     * 查询“userName&nbsp;=&nbsp;body.phone的用户(USER)”是否存在，如果存在，抛出异常201；(√) <br/>
     * 2.&nbsp;创建用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据body创建用户user_1，同时设置以下属性： <br/>
     * (1)&nbsp;user_1.phone&nbsp;=&nbsp;body.phone； <br/>
     * (2)&nbsp;user_1.companyId&nbsp;=&nbsp;0； <br/>
     * (3)&nbsp;user_1.deptId&nbsp;=&nbsp;0； <br/>
     * (4)&nbsp;user_1.isNewUser&nbsp;=&nbsp;否； <br/>
     * (5)&nbsp;user_1.userCode&nbsp;=&nbsp;'0'； <br/>
     * (6)&nbsp;user_1.resourceCode&nbsp;=&nbsp;'0'； <br/>
     * (7)&nbsp;user_1.type&nbsp;=&nbsp;'3'； <br/>
     * 3.&nbsp;分配权限&nbsp;:&nbsp;(√) <br/>
     * 为用户分配id=6的角色 <br/>
     * 4.&nbsp;提交以上事务 <br/>
     * 5.&nbsp;登录&nbsp;:&nbsp;(√) <br/>
     * 使用user_1.userName和user_1.password调用登录服务(login-service:&nbsp;/tokens&nbsp;GET)进行登录； <br/>
     * 6.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * 根据条件参数查询更新结果，组装响应并返回； <br/>
     * @param header <br/>
     * _token : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 令牌;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-code : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户代码;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-user-name : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户名;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-company-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 公司编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-dept-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 部门编号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/>
     * _hzhr-user-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE');<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-id : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易流水号;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-transaction-type : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 交易类型;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : true;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _hzhr-access-mode : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 访问模式 0:一般 1:全局;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : 0;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : int;<br/><br/>
     * @param query <br/>
     * _show : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 展示形式 one:展示一个,list:展示列表,null(空值):不展示;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : string;<br/>
     * _show_info : <br/>&nbsp&nbsp&nbsp&nbsp 说明 : 是否展示详情;<br/>&nbsp&nbsp&nbsp&nbsp 是否必填 : false;<br/>&nbsp&nbsp&nbsp&nbsp 默认值 : false;<br/>&nbsp&nbsp&nbsp&nbsp 数据类型 : boolean;<br/><br/>
     * @param body <br/><br/>
     * @throws ServiceException <br/>
     * @see User_RegistInfoPostModel body <br/>
     * @see User_RegistInfoGetModel result <br/>
     */ 
    //endregion
    //region 说明 : post1
    //新用户注册
    //简介 : 创建用户；登录
    //步骤 :
    //1. 验证用户名 : (√)
    //查询“userName = body.phone的用户(USER)”是否存在，如果存在，抛出异常201；(√)
    //2. 创建用户 : (√)
    // 根据body创建用户user_1，同时设置以下属性：
    //(1) user_1.phone = body.phone；
    //(2) user_1.companyId = 0；
    //(3) user_1.deptId = 0；
    //(4) user_1.isNewUser = 否；
    //(5) user_1.userCode = '0'；
    //(6) user_1.resourceCode = '0'；
    //(7) user_1.type = '3'；
    //3. 分配权限 : (√)
    //为用户分配id=6的角色
    //4. 提交以上事务
    //5. 登录 : (√)
    //使用user_1.userName和user_1.password调用登录服务(login-service: /tokens GET)进行登录；
    //6. 返回信息 : (√)
    //根据条件参数查询更新结果，组装响应并返回；
    //endregion
    //region 参数 : post1
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })

    //endregion
    //region 请求 : post1
    @RequestMapping(value = "/v1/users/regist-infos", method = RequestMethod.POST)
    //endregion
    public User_RegistInfoGetModel post1(Map<String, String> header, Map<String, Object> query,
                                        User_RegistInfoPostModel body) throws ServiceException {
        /* 验证用户名 */
        long phone = body.getPhone();
        UserCustomQueryModel userCustomQueryModel = new UserCustomQueryModel();
        userCustomQueryModel.setEqual_userName(phone + "");
        userCustomQueryModel.setEqual_isValid(CommonOptions.YES_NO.YES);
        int existCount = userDao.selectCount(userCustomQueryModel);
        if (existCount > 0) {
            throw new ServiceException(User_ErrorsEnum.USER_REGISTINFOSERVICE_POST_201);
        }

        /* 创建用户 */
        UserEntity user_1 = new UserEntity();
        user_1.setUserName(phone + "");
        user_1.setPhone(phone);
        user_1.setPassword(body.getPassword());
        user_1.setCompanyId(0);
        user_1.setDeptId(0);
        user_1.setEmail(body.getEmail());
        user_1.setIsNewUser(CommonOptions.YES_NO.YES);
        user_1.setCreateTime(new Date());
        user_1.setCreateUserId(0);
        user_1.setUserCode("0");
        user_1.setResourceCode("0");
        user_1.setIsValid(CommonOptions.YES_NO.YES);
        user_1.setState("1");
        user_1.setType(userOptions.getCode(UserOptionsTypeName.USER_TYPE, UserOptionsName.USER_TYPE.FREE));
        int changeCount = userDao.insert(user_1);

        /* 分配权限 */
        UserInRoleEntity userInRoleEntity = new UserInRoleEntity();
        userInRoleEntity.setUserId(user_1.getId());
        userInRoleEntity.setRoleId(6);
        userInRoleDao.insert(userInRoleEntity);

        /* 提交以上事务 */

        /* 登陆 */
        Map<String, String> header1 = new HashMap<>();
        header1.put("user-name", user_1.getUserName());
        header1.put("password", user_1.getPassword());
        Map<String, Object> query1 = new HashMap<>();
        TokenModel tokenModel = login_tokenService.get(header1, query1);

        /* 返回信息 */
        query.put("_equal_id", user_1.getId());
        User_RegistInfoGetModel result = user_registInfoService.get(initHeader(header, AccessModeEnum.GLOBAL), query);
        result.setChangeCount(changeCount);
        return result;
    }

    //region javadoc注释 : get
    /**
     * 查询用户的完善注册信息 <br/><br/>
     * 简介&nbsp;:&nbsp;查询用户的注册信息 <br/>
     * 步骤&nbsp;: <br/>
     * 1.&nbsp;查询用户&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据条件参数查询用户(USER)； <br/>
     * 2.&nbsp;返回信息&nbsp;:&nbsp;(√) <br/>
     * &nbsp;根据条件参数和查询到的结果组装响应并返回； <br/>
     * @param header <br/><br/>
     * @param query <br/><br/>
     * @throws ServiceException <br/>
     * @see User_RegistInfoGetModel result <br/>
     */ 
    //endregion
    //region 说明 : get
    //查询用户的完善注册信息
    //简介 : 查询用户的注册信息
    //步骤 :
    //1. 查询用户 : (√)
    // 根据条件参数查询用户(USER)；
    //2. 返回信息 : (√)
    // 根据条件参数和查询到的结果组装响应并返回；
    //endregion
    //region 参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where dept.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where dept.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/users/regist-infos", method = RequestMethod.GET)
    //endregion
    public User_RegistInfoGetModel get(Map <String, String> header, Map<String, Object> query) throws ServiceException {
        /* 查询用户 */
        //生成查询模型
        UserCustomQueryModel queryModel = userCustomConvertor.user_RegistInfoService_query2queryModel(query);
        queryModel.setEqual_isValid(CommonOptions.YES_NO.YES);
        //查询实体
        List<UserEntityExt> extList = null;
        String show = HzhrTypeUtil.object2string(query.get("_show"));
        if (!StringUtils.isEmpty(show)) {
            extList = userDao.selectExtList(queryModel);
        }
        //查询数量
        Integer total = null;
        Boolean showTotal = HzhrTypeUtil.object2boolean(query.get("_show_total"));
        if (showTotal != null && showTotal) {
            total = userDao.selectCount(queryModel);
        }

        /* 返回信息 */
        User_RegistInfoGetModel result = userCustomConvertor.extList2user_RegistInfoGetModel(extList, total, null, query);
        return result;
    }
}









































































































